﻿
using AutoMapper;
using System;
using System.Collections.Generic;
using System.DirectoryServices;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using VM.Common.Result;
using VM.Entity.EntityDto;
using VM.Entity.EntityDto.EnTry;
using VM.Entity.EntityDto.Goods;
using VM.Entity.EntityDto.ICon;
using VM.Entity.EntityDto.Lunbo;
using VM.Entity.EntityDto.Member;
using VM.Entity.EntityDto.Menu;
using VM.Entity.EntityDto.Order;
using VM.Entity.EntityDto.People;
using VM.Entity.EntityDto.ShopCar;
using VM.Entity.EntityDto.System.Code;
using VM.Entity.EntityDto.TitleDto;
using VM.Entity.EntityDto.Topic;
using VM.Entity.EntityMap;
using VM.Entity.EntityMap.EnTry;
using VM.Entity.EntityMap.Goods;
using VM.Entity.EntityMap.ICon;
using VM.Entity.EntityMap.Lunbo;
using VM.Entity.EntityMap.Member;
using VM.Entity.EntityMap.Menu;
using VM.Entity.EntityMap.Order;
using VM.Entity.EntityMap.People;
using VM.Entity.EntityMap.ShopCar;
using VM.Entity.EntityMap.System.Code;
using VM.Entity.EntityMap.Title;
using VM.Entity.EntityMap.Topic;

namespace VM.IBLL
{
    public class AutoMapperConfigs : Profile
    {
        public AutoMapperConfigs()
        {
            #region 例子
            //在这里就可以配置映射关系了
            //CreateMap<SystemLog, SystemLogDto>()
            //   .ForMember(c => c.StringDateTime, s => s.MapFrom(x => x.Date.ToString("yyyy年MM月dd日 HH:mm:ss")))
            //    .ReverseMap();
            //CreateMap<PagingData<SystemLog>, PagingData<SystemLogDto>>().ReverseMap();


            //CreateMap<User, UserDto>()
            //  .ReverseMap();
            //CreateMap<PagingData<User>, PagingData<UserDto>>().ReverseMap();

            //CreateMap<PagingData<sys_titleParent>, PagingData<titleListDto>>();

            #endregion
            #region order
            CreateMap<getOrderInfoDto, sys_order>()
          .ReverseMap();
            CreateMap<getOrderMainInfoDto, sys_order>()
         .ReverseMap();
            CreateMap<addOrderDto,  sys_order>()
           .ReverseMap();
            CreateMap<getOrderListDto, sys_order>()
           .ReverseMap();
            CreateMap<PagingData<sys_order>, PagingData<getOrderListDto>>()
           .ReverseMap();
            CreateMap<getOrderPeopleInfoDto,sys_orderPeople >()
           .ReverseMap();




            #endregion

            #region lunbo
            CreateMap<PagingData<sys_lunbo>, PagingData<getLunboListDto>>()
           .ReverseMap();

            #endregion

            #region shopCar
            CreateMap<sys_shopCar, addshopCarDto>().ReverseMap();
            CreateMap<sys_shopCar, getShopCarListDto>().ReverseMap();
            CreateMap<PagingData<sys_shopCar>, PagingData<getShopCarListDto>>()
           .ReverseMap();

            #endregion

            #region peopleInfo
            CreateMap<people_info, addPeopleInfoDto>().ReverseMap();
            CreateMap<people_info, getPeopleInfoDetailDto>().ReverseMap();
            CreateMap<people_info, getPeopleInfoListDto>().ReverseMap();
            CreateMap<people_info, updatePeopleInfoDto>().ReverseMap();

            CreateMap<PagingData<people_info>, PagingData<getPeopleInfoListDto>>().ReverseMap();
                  




            #endregion

            #region Good
            CreateMap<sys_goodsType, addGoodsTypeDto>().ReverseMap();
            CreateMap<good_headImgs, addGoodsHeadImgsDto>().ReverseMap();
            CreateMap<good_contentInfo, addGoodsContentInfoDto>().ReverseMap();
            CreateMap<good_applyNotes, addGoodsApplyNotesDto>().ReverseMap();
            CreateMap<good_mainInfo, addGoodsMainInfoDto>().ReverseMap();
            CreateMap<good_mainInfo, getGoodsListByTypeIdDto>().ForMember(dest => dest.imgSrc, opt => opt.MapFrom(src => src.headImgs[0].mediaSrc)).ReverseMap();
            CreateMap<PagingData<good_mainInfo>, PagingData<getGoodsListByTypeIdDto>>().ReverseMap();
            CreateMap<good_mainInfo, getGoodsInfoByIdDto>().ReverseMap();
            CreateMap<addGoodSpecDto, good_spec>().ReverseMap();
            #endregion

            #region menu
            CreateMap<sys_menu, addMenuDto>().ReverseMap();
            CreateMap<sys_menuMeta, addmenuMetaDto>().ReverseMap();

            CreateMap<sys_menu, menuInfoDetailDto>().ReverseMap();
            CreateMap<sys_menuMeta, menuMetaInfoDetailDto>().ReverseMap();
            
            //无限树形循环，需要指明内部的对应关系
            CreateMap<sys_menu, getMenuTreeListDto>().ForMember(dest => dest.children, opt => opt.MapFrom(src => src.children)) ;
            CreateMap<sys_menu, getMenuListDto>().ReverseMap();
            CreateMap<PagingData<sys_menu>, PagingData<getMenuListDto>>().ReverseMap();
             
            #endregion

            #region system/code
            CreateMap<sys_codeRule, getCodeRuleListDto>().ReverseMap();
            CreateMap<PagingData<sys_codeRule>, PagingData<addCodeRuleDto>>().ReverseMap();
            CreateMap<sys_codeRule, addCodeRuleDto>() .ReverseMap();
            CreateMap<sys_codeRule, updateCodeRuleDto>().ReverseMap();
            CreateMap< PagingData<sys_codeRule>, PagingData <getCodeRuleListDto >>().ReverseMap();
            #endregion

            #region title
            CreateMap<PagingData<sys_titleParent>, PagingData<titleListDto>>()
           .ReverseMap();
            CreateMap<sys_titleParent, titleListDto>()
          .ReverseMap();
            CreateMap<sys_titleMainInfo, titleMainInfoDto>()
           .ReverseMap();

            CreateMap<sys_titleTopic, titleTopicDto>()
           .ReverseMap();

            CreateMap<sys_titleParent, titleDetailDto>()
           .ReverseMap();


            #endregion

            #region topic
            CreateMap<PagingData<sys_topicType>, PagingData<getTopicTypeListDto>>()
           .ReverseMap();
            CreateMap<sys_topicType,addtopicTypeDto>()
           .ReverseMap();
            
            CreateMap<sys_topic, topicDto>()
             .ReverseMap();
             
            CreateMap<sys_topicType, getTopicTypeListDto>()
             .ReverseMap();
            #endregion 

            #region member

            CreateMap<sys_member, MemberInfoDto>()
              .ReverseMap();

            #endregion

            #region icon
            CreateMap<sys_icon, addIconDto>().ReverseMap();
            CreateMap<sys_icon, getIconListDto>().ReverseMap();
            CreateMap<PagingData<sys_icon>, PagingData<getIconListDto>>().ReverseMap();
            #endregion

            #region Entry
            CreateMap<sys_entry, addEntryDto>().ReverseMap();
            CreateMap<sys_userEntryLink, addUserEntryLinkDto>().ReverseMap();

            #endregion


        }
    }
}
